<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<base href="<%=basePath%>"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>审核记录</title>
		<link rel="stylesheet" href="res/layui/css/layui.css">
		<script src="res/js/jquery-2.1.4.min.js" type="text/javascript" ></script>
		<script src="res/layui/layui.js"></script>
	</head>
	<body style="padding: 40px 0px 40px 20px">
		<ul class="layui-timeline" id="examMsg">
		  <!-- <li class="layui-timeline-item">
		    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
		    <div class="layui-timeline-content layui-text">
		      <h3 class="layui-timeline-title">8月18日</h3>
		      <p>
		        layui 2.0 的一切准备工作似乎都已到位。发布之弦，一触即发。
		        <br>不枉近百个日日夜夜与之为伴。因小而大，因弱而强。
		        <br>无论它能走多远，抑或如何支撑？至少我曾倾注全心，无怨无悔 <i class="layui-icon"></i>
		      </p>
		    </div>
		  </li> -->
		</ul>
		<script type="text/javascript">
			var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
			
			var entryId;
			var type;
			
			$(function (){
				entryId = GetQueryString("entryId");
				type = GetQueryString("type")
				if(entryId!=null){
					var url = "exam/queryExamOld.action";
					var data = {"entryId":entryId};
					$.post(url, data, function(info){
						var index = 0;
						for(i=0; i<info.length; i++){
							var obj = info[i];
							obj.EXAM_TIME = new Date(obj.EXAM_TIME).Format("yyyy年MM月dd日 hh:mm:ss");
							var state = "";
							if(obj.EXAM_ISVO==1){
								state = "<font color='orange'>（财务通过）</font>";
							}else if(obj.EXAM_ISVO==2){
								state = "<font color='blue'>（经理通过）</font>";
							}else if(obj.EXAM_ISVO==3){
								state = "<font color='red'>（打回）</font>";
							}
							if(obj.roleName=='总店经理' && index==0){
								$('#examMsg').prepend('<li class="layui-timeline-item"><i class="layui-icon layui-timeline-axis">&#xe63f;</i><div class="layui-timeline-content layui-text"><div class="layui-timeline-title">已完成</div></div></li>');
								index++;
							}
							$("#examMsg").append('<li class="layui-timeline-item"><i class="layui-icon layui-timeline-axis">&#xe63f;</i><div class="layui-timeline-content layui-text"><h3 class="layui-timeline-title">'+obj.EXAM_TIME+state+'</h3><p>审核人:'+obj.EXAM_OPINOIN+'('+obj.roleName+')<br/>审核备注：'+obj.EXAM_remark+'</p></div></li>');
						} 
						$("#examMsg").append('<li class="layui-timeline-item"><i class="layui-icon layui-timeline-axis">&#xe63f;</i><div class="layui-timeline-content layui-text"><div class="layui-timeline-title">订单提交成功</div></div></li>');
					}); 
				}
				if(type==1){
					$('#examMsg').prepend('<li class="layui-timeline-item"><i class="layui-icon layui-timeline-axis">&#xe63f;</i><div class="layui-timeline-content layui-text"><div class="layui-timeline-title">等待总店审核</div></div></li>');
					$.post('exam/queryExamFdOld.action', {"fdproId":entryId}, function (info){
						var index = 0;
						for(i=0; i<info.length; i++){
							var obj = info[i];
							obj.EXAM_TIME = new Date(obj.EXAM_TIME).Format("yyyy年MM月dd日 hh:mm:ss");
							var state = "";
							if(obj.EXAM_ISVO==1){
								state = "<font color='orange'>（财务通过）</font>";
							}else if(obj.EXAM_ISVO==2){
								state = "<font color='blue'>（经理通过）</font>";
							}else if(obj.EXAM_ISVO==3){
								state = "<font color='red'>（打回）</font>";
							}
							$("#examMsg").prepend('<li class="layui-timeline-item"><i class="layui-icon layui-timeline-axis">&#xe63f;</i><div class="layui-timeline-content layui-text"><h3 class="layui-timeline-title">'+obj.EXAM_TIME+state+'</h3><p>审核人:'+obj.EXAM_OPINOIN+'('+obj.roleName+')<br/>审核备注：'+obj.EXAM_remark+'</p></div></li>');
							if(obj.roleName=='总店经理' && index==0){
								$('#examMsg').prepend('<li class="layui-timeline-item"><i class="layui-icon layui-timeline-axis">&#xe63f;</i><div class="layui-timeline-content layui-text"><div class="layui-timeline-title">已完成</div></div></li>');
								index++;
							}
						} 
					}); 
				}
			});
			
			/**
			得到URL栏的参数
			*/
			function GetQueryString(name){
			     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
			     var r = window.location.search.substr(1).match(reg);
			     if(r!=null)return  unescape(r[2]); return null;
			}
			
			/**
				格式化日期
			*/
			Date.prototype.Format = function (fmt) { //author: meizz 
			    var o = {
			        "M+": this.getMonth() + 1, //月份 
			        "d+": this.getDate(), //日 
			        "h+": this.getHours(), //小时 
			        "m+": this.getMinutes(), //分 
			        "s+": this.getSeconds(), //秒 
			        //"q+": Math.floor((this.getMonth() + 3) / 3), //季度 
			        "S": this.getMilliseconds() //毫秒 
			    };
			    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
			    for (var k in o)
			    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
			    return fmt;
			} 
		</script>
	</body>
</html>